package com.xczz.common.result;

import com.xczz.common.constant.HttpStatus;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class TableDataInfo implements Serializable {
    private long total;
    private List<?> rows;
    private int code;
    private int msg;

    public TableDataInfo(){}

    public TableDataInfo(List<?> list,long total){
        this.rows=list;
        this.total=total;
    }

    public static TableDataInfo success(List<?> list,long total){
        TableDataInfo tableDataInfo=new TableDataInfo(list,total);
        tableDataInfo.setCode(HttpStatus.SUCCESS);
        return tableDataInfo;
    }

    public static TableDataInfo failure(int msg){
        TableDataInfo tableDataInfo=new TableDataInfo();
        tableDataInfo.setCode(HttpStatus.ERROR);
        tableDataInfo.setMsg(msg);
        return tableDataInfo;
    }
}
